/*
** Copyright (c) K-Marrade
** All rights reserved.
**
** write.c : Contains the syscall write ().
**
** Use with caution.
**
*/
#ifndef GDT_H_
# define GDT_H_

typedef struct
{
    int seg_limit:16;
    int base_addr:16;
    char base:8;
    char type:4;
    char descriptor:1;
    char dpl:2;
    char present:1;
    char limit:4;
    char avl:1;
    char x64:1;
    char default_op_size:1;
    char granularity:1;
    char base2:8;
} __attribute__ ((packed)) t_segment_descriptor;

typedef struct
{
    int limit:16;
    t_uint32 gdt:32;
} __attribute__ ((packed)) t_gdtr;

void gdt_init ();

void gdt_init_userland(t_uint32 code_base_addr,
		       t_uint32 code_limit,
		       t_uint32 data_base_addr,
		       t_uint32 data_limit);

void gdt_add_entry(int index,
		   t_uint32 base_addr,
		   t_uint32 seg_limit,
		   char access_byte,
		   char flags);

t_segment_descriptor* gdt_get_user_data(void);

#endif /* !GDT_H_ */
